<script type="text/javascript">
function SelectAll(checkboxall)
{
	$(".updatecheckbox").attr("checked", checkboxall.checked);
}
</script>

<div class="deal">
<div class="deal_content_top"></div>
<div class="deal_content">
<h3>Quản lý đơn đặt hàng</h3>
<table class="table-style" style="width: 100%;" cellpadding="5px"
	cellspacing="0">
	<tbody>
		<tr class="table-title">
			<td><input type="checkbox" onchange="SelectAll(this);" /></td>
			<td><a href="<?php echo $this->baseUrl("index.php/admin_cms/order") ?>?by=a.order_id&order=<?php echo ($this->by != "a.order_id" || $this->order == "desc") ? "asc" : "desc"; ?>">ID</a></td>
			<td><a href="#">Deal</a></td>
			<td><a href="<?php echo $this->baseUrl("index.php/admin_cms/order") ?>?by=a.status&order=<?php echo ($this->by != "a.status" || $this->order == "desc") ? "asc" : "desc"; ?>">Trạng thái</a></td>
			<td><a href="<?php echo $this->baseUrl("index.php/admin_cms/order") ?>?by=b.name&order=<?php echo ($this->by != "b.name" || $this->order == "desc") ? "asc" : "desc"; ?>">Thanh toán</a></td>
			<td>&nbsp;</td>
		</tr>
		<?php
		if (count($this->paginator) == 0) {
			echo "<tr><td colspan='3' align='center'>No order</td></tr>";
		} else {
			?>
			<form action="" method="post">
			<?php $i = 0 ?>
			<?php foreach ($this->paginator as $order): ?>
		<tr class="<?php echo $i % 2 == 0 ? 'even' : 'odd' ?>">
			<td><input class="updatecheckbox" type="checkbox" name="checkbox[]" value="<?php echo $order->order_id ?>" /></td>
			<td><?php echo $order->order_id ?></td>
			<td>
				<?php
				$content = "";
				for($i = 0; $i < count($order->deal_id); $i++)
				{
					$link = $this->baseUrl('index.php/cms/index/deal/id/' . $order->deal_id[$i]);
					
					if(strlen($order->deal_title[$i]) < 30)
					{
						$title = $order->deal_title[$i];
					}
					else
					{
						$title = substr($order->deal_title[$i], 30) . " ...";
					}
					
					$content .= "<a href='$link'>$title</a><br />";
				}
				echo $content;
				?>
			</td>
			<td><?php echo $this->enumStatus[$order->status] ?></td>
			<td><?php echo $order->name ?></td>
			<td align="right">
                <a href="<?php echo $this->baseUrl('index.php/admin_cms/order/edit/id/'.$order->order_id) ?>">
                            <img alt="Edit" src="<?php echo $this->baseUrl('public/images/edit.png') ?>">
                </a>
                <a href="<?php echo $this->baseUrl('index.php/admin_cms/order/delete/id/'.$order->order_id) ?>" onclick="if(!confirm('Delete ?',''))return false;">
                    <img alt="Delete" src="<?php echo $this->baseUrl('public/images/delete.png') ?>">
                </a>
			</td>
		</tr>
		<?php $i++ ?>
		<?php endforeach ?>
		<tr>
			<td colspan="5">
				<?php $order_status = Zend_Registry::get("order_status"); ?>
				Trạng thái
				&nbsp;&nbsp;
				<select name="status">
					<?php
					for($i = 1; $i <= count($order_status); $i++)
					{
						echo "<option value='$i'>{$order_status[$i]}</option>";
					}
					?>
				</select>
				&nbsp;&nbsp;
				<input type="submit" value="Cập nhật" />
			</td>
		</tr>
		</form>
		<?php } ?>
	</tbody>
</table>
		
<?php echo $this->paginator; ?>
</div>

<div class="deal_content_bottom"></div>
</div>
